package com.example.administrator.printoutindemo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;


public class StoreOutStorageCheckList2Adapter extends BaseAdapter{
	private Context mContext = null;
	private List<OutStorageMaterialCheckList> li = null;
	private LayoutInflater mInflater = null;

	private class ViewHolder {
		TextView s_cl_ada2_txt_title;
		TextView tv_wu_liao_miao_shu;
		TextView tv_yu_ling_liao_shu_liang;
		TextView tv_shu_liang_dan_wei;
		TextView tv_yu_ji_ling_liao_shi_jian;
		TextView tv_shen_qing_ren;
	}
	private ViewHolder holder = null;

	public StoreOutStorageCheckList2Adapter(Context mContext) {
		this.mContext = mContext;
	}

	public void setList(List<OutStorageMaterialCheckList> li) {
		this.li = li;
		this.mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		return li.size();
	}
	@Override
	public Object getItem(int position) {
		return li.get(position);
	}
	@Override
	public long getItemId(int position) {
		return position;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		if (null == convertView) {
			holder = new ViewHolder();

			convertView = mInflater.inflate(R.layout.store_adapter_outstoragechecklist_2, null);

			holder.s_cl_ada2_txt_title = (TextView) convertView.findViewById(R.id.s_cl_ada2_txt_title);
			holder.tv_wu_liao_miao_shu = (TextView) convertView.findViewById(R.id.tv_wu_liao_miao_shu);
			holder.tv_yu_ling_liao_shu_liang = (TextView) convertView.findViewById(R.id.tv_yu_ling_liao_shu_liang);
			holder.tv_shu_liang_dan_wei = (TextView) convertView.findViewById(R.id.tv_shu_liang_dan_wei);
			holder.tv_yu_ji_ling_liao_shi_jian = (TextView) convertView.findViewById(R.id.tv_yu_ji_ling_liao_shi_jian);
			holder.tv_shen_qing_ren = (TextView) convertView.findViewById(R.id.tv_shen_qing_ren);

			convertView.setTag(holder);
		}
		else {
			holder = (ViewHolder) convertView.getTag();
		}

		if (null != this.li) {

			OutStorageMaterialCheckList o = li.get(position);

			String str = "项目名称："+o.get_projectname()
					+"\n物料描述："+o.get_material()
					+"\n预出库数量："+o.get_out_storage_count()
					+"\n数量单位："+o.get_unit()
					+"\n预出库时间："+o.get_out_storage_Estimate()
					+"||"+o.get_out_storageList_id()
					+"\n提交人:"+o.get_user_name();

			holder.s_cl_ada2_txt_title.setText(o.getProid());
			holder.tv_wu_liao_miao_shu.setText(o.get_material());
			holder.tv_yu_ling_liao_shu_liang.setText(o.get_out_storage_count());
			holder.tv_shu_liang_dan_wei.setText(o.get_unit());
			holder.tv_yu_ji_ling_liao_shi_jian.setText(o.get_out_storage_Estimate());
			holder.tv_shen_qing_ren.setText(o.get_user_name());

		}


		return convertView;
	}

}